package com.aurora.gulimall.search;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

import java.net.InetAddress;
import java.net.UnknownHostException;
@Slf4j
@SpringBootApplication
@EnableDiscoveryClient
public class GulimallSearchApplication {
    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(GulimallSearchApplication.class, args);
        ConfigurableEnvironment environment = applicationContext.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = environment.getProperty("server.port");
        String path = environment.getProperty("server.servlet.context-path");
        path = path == null?"":path;
        StringBuffer sb = new StringBuffer();
        sb.append("\n-------------------------------------------\n\t");
        sb.append("Applicaiton service is running!\n\t");
        sb.append("Address:http://"+ip+":"+port+"/"+path+"\n\t");
        sb.append("-------------------------------------------\n\t");
        log.info(sb.toString());
    }
}
